﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Actuant.MOSS.TimeJob
{
    public class SMSTaskJob : SPJobDefinition
    {
        const string ListName = "PickCarList";

        SPSite site;

        public SMSTaskJob()
            : base()
        {

        }

        public SMSTaskJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(jobName, service, server, targetType)
        {
            
        }

        public SMSTaskJob(string jobName, SPWebApplication webApplication)
            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "Pick Car List, and send sms if match the rule";
        }

        public override void Execute(Guid targetInstanceId)
        {
            base.Execute(targetInstanceId);

            SPWebApplication web = this.WebApplication; // this.parent as SPWebApplication
            SPContentDatabase contentdb = web.ContentDatabases[targetInstanceId];
            site = contentdb.Sites[0];
            SPWeb spweb = site.RootWeb;
            SPList lists = spweb.Lists[ListName];
            SPListItemCollection listItems = lists.Items;
            
            // lists.EventReceivers.Add
        }
    }
}
